<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>在线鲜花销售网</title>
<meta name="keywords" content="鲜花，鲜花速递，鲜花网，花店，开业花篮" />
<meta name="description" content="各种鲜花绿植，应有尽有" />
<link href="images/xicon.png" rel="shortcut icon" type="image/x-icon" />
<link href="css/header.css" rel="stylesheet" type="text/css" />
<link href="css/index.css" rel="stylesheet" type="text/css" />
<link href="css/footer.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/detail.css" type="text/css" >
</head>

<body>
<!-- 顶部区域 -->
<header id="header">
	<!-- 顶部标题区域 -->
	<div class="htitle">
    	<a href="#" target="_blank" class="location">衡阳</a>
        
        <div class="header-info">
            <div class="login-info">
            	
            </div>
            
            <div class="person-info">
            	<span>|</span>
            	<a href="order.html" target="_blank">我的订单</a>
                <span>|</span>
                <a href="#" target="_blank">我的鲜花</a>
                <span>|</span>
                <a href="#" target="_blank">客户服务</a>
                <span>|</span>
           		<a href="#" target="_blank">个人信息</a>
            </div>
        
        </div>
    </div>
    
    <!-- 顶部搜索区域 -->
    <div class="search">
    	<div class="search_left">
    		<a href="index.html" title="首页">
            	<img src="images/logo.png" width="260px" height="120px"/> 
            </a>
        </div>
        
        <div class="search_right">
        	<div class="search_top">
                <div class="search_div">
                    <input type="search" class="search-ipt" placeholder="请输入要搜索的内容" />
                    <input type="button" class="search-btn"  onclick = "searchGoods()"/>  
                </div>
                <div class="buycart">
                	<i class="iconfont">0</i>
                    <a href="cart.html" target="_blank" onclick="toCart()">我的购物车</a>
                </div>
            </div>
            
            <div class="search_item" id="search_item">   
            </div>
        </div>
    </div>
</header>
     
<!-- 面包屑导航 --> 
<div class="breadcrumb" id="breadcrumb">
    <a href="javascript:void(0)">全部分类</a>
    <span>&gt;</span>
    <a href="javascript:void(0)" id="goods_type">鲜花</a>
    <span>&gt;</span>
    <a href="javascript:void(0)">商品详情</a>
 </div>
     
<!-- 商品展示 -->
<div class="goods_details_con clearfix">
    <div class="goods_details_pic fl">
        <img src="images/goods/good03.jpg">
    </div>
    <div class="goods_details_list fr">
        <h3 id="view_gname"></h3>
        <p id="view_intro"></p>
        <div class="price_bar">
            <span class="show_price" >&yen;<em  id="view_price"></em>元</span>
            <span class="show_unit" >单位：<em  id="view_unit"></em></span>
        </div>
        <div class="goods_num clearfix">
            <div class="num_name fl">数量：</div>
            <div class="num_add fl">
                <input type="text" class="num_show fl" value="1" id="goods_count">
                <a href="javascript:addCount(1)" class="add fr">+</a>
                <a href="javascript:addCount(-1)" class="minus fr">-</a>	
            </div>
            <div class="balance_cls">仓库量<span id="store_num"></span> 朵</div>
        </div>
        <div class="total">总价：<em  id="total_price">16.80</em>元</div>
        <div class="operate_btn">
            <a href="javascript:;" class="buy_btn" id="buy_btn">立即购买</a>
            <a href="javascript:void(0);" class="add_cart" id="add_cart" >加入购物车</a>				
        </div>
    </div>
</div>

<!-- 商品详情 -->
<div class="main_wrap clearfix">
    <div class="l_wrap fl clearfix">
        <div class="new_goods">
            <h3>新品推荐</h3>
            <ul>
                <li>
                    <a href="#"><img src="images/goods/1001.jpg"></a>
                    <h4><a href="#">每日鲜花</a></h4>
                    <div class="prize">&yen;388</div>
                </li>
                <li>
                    <a href="#"><img src="images/goods/1010.jpg"></a>
                    <h4><a href="#">多彩永生花</a></h4>
                    <div class="prize">&yen;268</div>
                </li>
            </ul>
        </div>
    </div>

    <div class="r_wrap fr clearfix">
        <ul class="detail_tab clearfix">
            <li class="active">商品介绍</li>
            <li>评论</li>
            <li>推荐</li>
        </ul>

        <div class="tab_content">
            <dl>
                <dt>商品详情：</dt>
                <dd  id="view_descr"> </dd>
            </dl>
        </div>

    </div>
</div>
<div class="popup_con">
	<div class="popup">
		<p id="popup_info"></p>
	</div>
</div>    
<!-- 版权所有 -->
<footer>
	<div class="fservice">
		<ul class="clearfix">
			<li>
				<span>
					<img src="images/f01.png" >
					<a href="#">热诚服务</a>
				</span>
			</li>
			<li><span><img src="images/f02.png" ><a href="#">客户信赖</a></span></li>
			<li><span><img src="images/f03.png" ><a href="#">时尚原创花艺</a></span></li>
			<li><span><img src="images/f04.png" ><a href="#">订单实拍</a></span></li>
			<li><span><img src="images/f05.png" ><a href="#">优惠多多</a></span></li>
			<li><span><img src="images/f06.png" ><a href="#">1小时配送</a></span></li>
			<li><span><img src="images/f07.png" ><a href="#">售后服务</a></span></li>
		</ul>
	</div>
	
	<div class="foot_link">
        <a href="#">关于我们</a> <span> | </span>
        <a href="#">联系我们</a> <span> | </span>
        <a href="#">招聘广告</a> <span> | </span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight &copy; 2021 <a class="copy" href="#" target="_blank">点心思在线鲜花销售系统</a> All Rights Reserverd</p>
    <p>电话：0734-7572842 湘ICP备12345678号-1</p>
</footer>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/checkLogin.js" type="text/javascript"></script>
<script src="js/addCart.js" type="text/javascript"></script>
<script>

let price = 0;
$(function(){
	let gno = location.hash.replace("#","");
	//但是，如果是真正情况下，没有那么简单
	if( gno == "" ){
		location.href = "index.html";
		return;
	}
	
	//发送ajax
	$.post("goods",{
		op: 'findByGno',
		gno: gno
	},function(data){
		if( data == null ){
			location.href = "index.html";
			return;
		}
	
		//将值显示到网页上
		$("#view_gname").html(data[0].gname);
		$("#view_intro").html(data[0].intro);
		$("#view_price").html(data[0].price);
		$("#view_unit").html(data[0].weight + "/"+data[0].unit);
		$("#store_num").html(data[0].balance);
		$("#total_price").html( (data[0].price * $("#goods_count").val()).toFixed(2) );
		//$( "view_descr").html(data[0].descr);
		$( "#view_descr").html(data[0].intro);
		
		$(".goods_details_pic img").attr("src","images/goods/"+data[0].pics.split(";")[0].split("_")[1]);
		$("#add_cart").click(function(){
			addCart(gno);
		});
		
	},"json");
})


function addCount(num) {
	var nums = parseInt($("#goods_count").val());
	var store_num = parseInt($("#store_num").val());
	nums += parseInt(num);
	if (nums <= 0) {
		$("#goods_count").val(1);
		return;
	}
	
	if (nums > store_num){
		$("#goods_count").val(store_num);
		return;
	}
	$("#goods_count").val(nums);
	console.log(parseInt($("#view_price").html()) * nums);
	$("#total_price").html(($("#view_price").html() * nums).toFixed(2));
}

/* function addCart() {
	$("#popup_info").text("加入购物车成功...");
	$('.popup_con').fadeIn('fast', function() {
		setTimeout(function(){
			$('.popup_con').fadeOut('fast',function(){
				// location.href = 'alipay/pay/' + data.msg +"/" + price;
			});	
		}, 2000)
	});
} */
</script>
</body>
</html>
